package exemple;

public class YouTubeDownLoad {

	
	/* Constants */
	String const_video_url_str = "http://www.youtube.com/watch?v=%s";
	//String const_video_url_re = re.compile(r'^((?:http://)?(?:\w+\.)?youtube\.com/(?:v/|(?:watch(?:\.php)?)?\?(?:.+&)?v=))?([0-9A-Za-z_-]+)(?(1)[&/].*)?$');
	String const_login_url_str = "http://www.youtube.com/login?next=/watch%%3Fv%%3D%s";
	String const_login_post_str = "current_form=loginForm&next=%%2Fwatch%%3Fv%%3D%s&username=%s&password=%s&action_login=Log+In";
	String const_age_url_str = "http://www.youtube.com/verify_age?next_url=/watch%%3Fv%%3D%s";
	String const_age_post_str = "next_url=%%2Fwatch%%3Fv%%3D%s&action_confirm=Confirm";
	//String const_url_t_param_re = re.compile(r"[,{]t:'([^']*)'");
	String const_video_url_real_str = "http://www.youtube.com/get_video?video_id=%s&t=%s";
	//String const_video_title_re = re.compile(r'<title>YouTube - ([^<]*)</title>', re.M | re.I);
	int const_1k = 1024;
	int const_initial_block_size = 10*const_1k;
	double const_epsilon = 0.0001;
	
	
	// Print error message, followed by standard advice information, and then exit
	public void error_advice_exit(String error_text){
		System.err.println("Error: "+error_text);
		System.err.println("Try again several times. It may be a temporary problem.");
		System.err.println("Other typical problems:");
		System.err.println("* Video no longer exists.");
		System.err.println("* Video requires age confirmation but you did not provide an account.");
		System.err.println("* You provided the account data, but it is not valid.");
		System.err.println("* The connection was cut suddenly for some reason.\n");
		System.err.println("* YouTube changed their system, and the program no longer works.");
		System.err.println("Try to confirm you are able to view the video using a web browser.");
		System.err.println("Use the same video URL and account information, if needed, with this program.");
		System.err.println("When using a proxy, make sure http_proxy has http://host:port format.");
		System.err.println("Try again several times and contact me if the problem persists.");
		System.exit(0);
	}
	
	/*Wrapper to create custom requests with typical headers
	def request_create(url, data=None):
		retval = urllib2.Request(url)
		if data is not None:
			retval.add_data(data)
		# Try to mimic Firefox, at least a little bit
		retval.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0')
		retval.add_header('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7')
		*/
		//retval.add_header('Accept', 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5')
		/*retval.add_header('Accept-Language', 'en-us,en;q=0.5')
		return retval
		*/
}
